package fox.framework.rpc.common;


import fox.framework.rpc.exception.RpcException;
import fox.framework.rpc.exception.RpcRuntimeException;

/**
 * @author cuichao
 * @Description: ExceptionUtils
 * @Date: create in 2020/12/29 22:39
 */
public class ExceptionUtils {

    public static RpcException RpcExceptionWrap(Throwable e){
        if(e instanceof  RpcException){
            return (RpcException) e;
        }
        return  new RpcException(e);
    }

    public static RpcException RpcExceptionWrap(Exception e){
        if(e instanceof  RpcException){
            return (RpcException) e;
        }
        return  new RpcException(e);
    }

    public static RpcRuntimeException RpcRuntimeExceptionWrap(Exception e){
        if(e instanceof  RpcRuntimeException){
            return (RpcRuntimeException) e;
        }
        return  new RpcRuntimeException(e);
    }


    public static RpcRuntimeException RpcRuntimeExceptionWrap(Throwable e){
        if(e instanceof  RpcRuntimeException){
            return (RpcRuntimeException) e;
        }
        return  new RpcRuntimeException(e);
    }
}
